﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AzukiMap.Layer;

namespace AzukiMapUI
{
	public partial class LayerExpressionDialog : UserControl
	{
        ILayer _layer;

        /*
        public ILayer Layer
        {
            get { return _layer; }
            set { 
                _layer = value;
                LayerVisibilityPart.Layer = value;
            }
        }
         */

		public LayerExpressionDialog(ILayer layer)
		{
			// Required to initialize variables
			InitializeComponent();
            _layer = layer;
            LayerVisibilityPart.Layer = layer;
            SetExpressionPart();
		}

        void SetExpressionPart()
        {
            if (_layer.Type == AzukiMap.MapSource.MapSourceTypes.Raster ||
                _layer.Type == AzukiMap.MapSource.MapSourceTypes.Tile)
            {
                TabExpression.Visibility = Visibility.Collapsed;
                return;
            }
            TabExpression.Visibility = Visibility.Visible;
            ExpressionSelectPart.VectorLayer = (IVectorLayer)_layer;
        }

        private void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            LayerVisibilityPart.SetAll();
            this.Visibility = Visibility.Collapsed;
        }

        private void BtnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Visibility = Visibility.Collapsed;
        }
	}
}